package com.ztstkj.lzboard.adapters

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.ztstkj.lzboard.R
import com.ztstkj.lzservices.dto.boards.BoardRealDeliveryOutput

class UserRealDeliveryAdapter(private var datas: List<BoardRealDeliveryOutput>): RecyclerView.Adapter<UserRealDeliveryAdapter.ItemViewHolder>(){
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder {
        val v = LayoutInflater.from(parent.context)
            .inflate(R.layout.real_delivery_item, parent, false)
        return ItemViewHolder(v)
    }

    override fun onBindViewHolder(holder: ItemViewHolder, position: Int) {
        val bean = datas[position]
        if(position%2==1){
            holder.itemView.setBackgroundResource(R.drawable.table_bg_odd) // 偶数行颜色
        }

        holder.realTime.text  = bean.createTimeAbb
        holder.realRoom.text  = bean.home
        holder.realCategory.text = bean.category
        holder.realWeight.text=bean.weight.toString()
        holder.realPoint.text=bean.point.toString()
    }

    override fun getItemCount(): Int {
        return datas.size
    }

    inner class ItemViewHolder(view: View): RecyclerView.ViewHolder(view){
        val realTime : TextView = view.findViewById(R.id.tvRealTime)
        val realRoom : TextView = view.findViewById(R.id.tvRealRoom)
        val realCategory : TextView = view.findViewById(R.id.tvRealCategory)
        val realWeight : TextView = view.findViewById(R.id.tvRealWeight)
        val realPoint : TextView = view.findViewById(R.id.tvRealPoint)
    }
}